import { get, post } from '@/utils/request'
import type { ApiResult } from '@/utils/request'

//获取字典详情根据code
export async function dict(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysDict/selectDictByCode/${params}`)
}

// 登录接口
export async function login(params?: any): Promise<ApiResult<any>> {
  return await post<any>('/manage/v1/login/login', params)
}

// 获取验证码
export async function captcha(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/login/captcha`, params, {
    responseType: 'blob'
  })
}

//修改密码
export async function updatePassword(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/login/updatePassword?newPwd=${params}`)
}

// 删除字典
export async function deleteSysMenu(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysMenu/deleteSysMenu`, params)
}

// 查询字典
export async function selectMenuList(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysMenu/selectMenuList`, params)
}

// 单个查询
export async function selectSysMenuById(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysMenu/selectSysMenuById`, params)
}

// 新增字段
export async function saveMenu(params?: any): Promise<ApiResult<any>> {
  return await post<any>('/manage/v1/sysMenu/saveMenu', params)
}

// 编辑字典
export async function updateMenu(params?: any): Promise<ApiResult<any>> {
  return await post<any>('/manage/v1/sysMenu/updateMenu', params)
}

export async function deleteDict(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysDict/delete/${params}`)
}

export async function pageSysDict(params?: any): Promise<ApiResult<any>> {
  return await post<any>('/manage/v1/sysDict/pageSysDict', params)
}

export async function selectDict(id?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysDict/select/${id}`)
}

export async function saveSysDict(params?: any): Promise<ApiResult<any>> {
  return await post<any>('/manage/v1/sysDict/saveSysDict', params)
}

export async function updateSysDict(params?: any): Promise<ApiResult<any>> {
  return await post<any>('/manage/v1/sysDict/updateSysDict', params)
}

export async function selectSysDictByParentId(parentId?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysDict/selectSysDictByParentId/${parentId}`)
}

export async function deleteRole(roleId?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysRole/delete/${roleId}`)
}

export async function selectRole(roleId?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysRole/select/${roleId}`)
}

export async function sysRolePage(params?: any): Promise<ApiResult<any>> {
  return await post<any>('/manage/v1/sysRole/page', params)
}

export async function authRoleMenu(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/auth/authRoleMenu`, params)
}

export async function selectAuthSysRoleList(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/auth/selectSysRoleList/${params}`)
}

export async function saveRole(params?: any): Promise<ApiResult<any>> {
  return await post<any>('/manage/v1/sysRole/saveRole', params)
}

export async function updateRole(params?: any): Promise<ApiResult<any>> {
  return await post<any>('/manage/v1/sysRole/updateRole', params)
}

export async function pageAuthSysUser(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/auth/pageSysUser`, params)
}

export async function selectOrgChildren(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysOrg/selectOrgChilds`, params)
}

//添加组织
export async function saveOrg(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/sysOrg/saveOrg`, params)
}
//编辑组织
export async function updateOrg(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/sysOrg/updateOrg`, params)
}
//删除组织
export async function deleteOrg(params?: any, id?: string): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysOrg/delete/${id}`, params)
}

export async function selectOrgChilds(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysOrg/selectOrgChilds`, params)
}

//添加用户
export async function saveSysUser(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/sysUser/saveSysUser`, params)
}
//编辑用户
export async function updateSysUser(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/sysUser/updateSysUser`, params)
}

//查询用户详情
export async function selectUserById(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysUser/selectUserById`, params)
}

//用户分页查询
export async function pageSysUser(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/sysUser/pageSysUser`, params)
}
// 重置密码
export async function resetPwd(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/login/resetPwd`, params)
}
//删除用户
export async function delSysUser(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/sysUser/delSysUser`, params)
}
// 用户授权角色
export async function authUserRole(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/auth/authUserRole`, params)
}

// 获取用户所授权角色
export async function selectRoleIdListByUserId(params?: any): Promise<ApiResult<any>> {
  return await get<any>(`/manage/v1/auth/selectRoleIdListByUserId/${params}`)
}
export async function selectSysRoleList(params?: any): Promise<ApiResult<any>> {
  return await post<any>(`/manage/v1/sysRole/selectSysRoleList`, params)
}
